{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "certain-rapid",
   "metadata": {},
   "source": [
    "# part0: imports"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "convinced-tracy",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os, pathlib\n",
    "try:\n",
    "    nbPath = pathlib.Path.cwd()\n",
    "    RepoPath = nbPath.parent\n",
    "    os.chdir(RepoPath)\n",
    "\n",
    "    from tools import utilityTools as utility\n",
    "    import params\n",
    "    defs = params.monkey_defs\n",
    "    \n",
    "    set_rc =  params.set_rc_params\n",
    "    root = params.root\n",
    "\n",
    "finally:\n",
    "    os.chdir(nbPath)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "industrial-think",
   "metadata": {},
   "source": [
    "#### Print the summary of all the datassets\n",
    "\n",
    "check out the results [here](https://github.com/AtMostafa/notebook/blob/main/2021-cca-project/dataset-summary.md)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "entire-rachel",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "_AllAnimalList = ['Chewie', 'Chewie2', 'Mihili', 'Jaco', \"Chips\", \"MrT\", 'Han', 'Lando']\n",
    "\n",
    "_AllAnimalFiles=[]\n",
    "for animal in _AllAnimalList:\n",
    "    _AllAnimalFiles.extend(utility.find_file(root / animal, 'mat'))\n",
    "\n",
    "# for i,fname in enumerate(_AllAnimalFiles):\n",
    "#     _df = pyal.mat2dataframe(fname, shift_idx_fields=True)\n",
    "#     print(i)\n",
    "#     dt.summary(_df)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "departmental-hands",
   "metadata": {},
   "source": [
    "Categories I want to separate:\n",
    "\n",
    "- sessions with 2 areas, similar number of neurons each, as many monkeys as possible!\n",
    "- 3 sessions for each area (M1, PMd, S1), most number of neurons"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "prescription-algorithm",
   "metadata": {},
   "outputs": [],
   "source": [
    "_AllAnimalFiles= [path.split(os.sep)[-1] for path in _AllAnimalFiles]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "grave-quarterly",
   "metadata": {},
   "outputs": [],
   "source": [
    "GoodDataList_CO = {'dualArea':{}, 'M1':{}, 'PMd':{}, 'S1':{}}\n",
    "\n",
    "#------------------------------------\n",
    "\n",
    "GoodDataList_CO['dualArea']['Chewie'] = ['Chewie_CO_VR_2016-09-14.mat',\n",
    "                                      'Chewie_CO_CS_2016-10-21.mat',\n",
    "                                      'Chewie_CO_FF_2016-10-05.mat',\n",
    "                                      'Chewie_CO_CS_2016-10-14.mat',\n",
    "                                      'Chewie_CO_FF_2016-10-13.mat'\n",
    "                                     ]\n",
    "\n",
    "GoodDataList_CO['dualArea']['Mihili'] = ['Mihili_CO_VR_2014-03-06.mat',\n",
    "                                      'Mihili_CO_VR_2014-03-03.mat',\n",
    "                                      'Mihili_CO_FF_2014-02-17.mat',\n",
    "                                      'Mihili_CO_VR_2014-03-04.mat'\n",
    "                                     ]\n",
    "\n",
    "GoodDataList_CO['dualArea']['MrT'] = ['MrT_CO_VR_2013-09-09.mat',\n",
    "                                   'MrT_CO_VR_2013-09-05.mat'\n",
    "                                  ]\n",
    "\n",
    "#-----------------------------------\n",
    "\n",
    "GoodDataList_CO['M1']['Chewie'] = ['Chewie_CO_VR_2016-09-14.mat',\n",
    "                                'Chewie_CO_FF_2016-10-13.mat',\n",
    "                                'Chewie_CO_CS_2016-10-21.mat',\n",
    "                                'Chewie_CO_CS_2016-10-14.mat'\n",
    "                               ]\n",
    "\n",
    "GoodDataList_CO['M1']['Chewie2'] = ['Chewie_CO_CS_2015-03-19.mat',\n",
    "                                 'Chewie_CO_CS_2015-03-13.mat',\n",
    "                                 'Chewie_CO_CS_2015-03-11.mat',\n",
    "                                 'Chewie_CO_CS_2015-03-12.mat'\n",
    "                                ]\n",
    "\n",
    "GoodDataList_CO['M1']['Mihili'] = ['Mihili_CO_VR_2014-03-06.mat',\n",
    "                                'Mihili_CO_VR_2014-03-03.mat',\n",
    "                                'Mihili_CO_FF_2014-02-17.mat'\n",
    "                               ]\n",
    "\n",
    "GoodDataList_CO['M1']['Jaco'] = ['Jaco_CO_CS_2016-01-28.mat',\n",
    "                              'Jaco_CO_CS_2016-02-04.mat',\n",
    "                              'Jaco_CO_CS_2016-02-17.mat'\n",
    "                             ]\n",
    "\n",
    "#-----------------------------------\n",
    "\n",
    "GoodDataList_CO['PMd']['Chewie'] = ['Chewie_CO_FF_2016-09-21.mat',\n",
    "                                 'Chewie_CO_VR_2016-09-14.mat',\n",
    "                                 'Chewie_CO_FF_2016-09-15.mat',\n",
    "                                 'Chewie_CO_FF_2016-09-19.mat'\n",
    "                                ]\n",
    "\n",
    "GoodDataList_CO['PMd']['Mihili'] = ['Mihili_CO_FF_2014-02-18.mat',\n",
    "                                 'Mihili_CO_CS_2014-09-29.mat',\n",
    "                                 'Mihili_CO_FF_2014-02-17.mat'\n",
    "                                ]\n",
    "\n",
    "GoodDataList_CO['PMd']['MrT'] = ['MrT_CO_VR_2013-09-05.mat',\n",
    "                              'MrT_CO_VR_2013-09-09.mat',\n",
    "                              'MrT_CO_FF_2013-08-21.mat'\n",
    "                             ]\n",
    "\n",
    "#-----------------------------------\n",
    "\n",
    "GoodDataList_CO['S1']['Chips'] = ['Chips_20151204_TD_nosort_notrack_noemg.mat',\n",
    "                               'Chips_20151201_TD_nosort_notrack_noemg.mat',\n",
    "                               'Chips_20151211_TD_nosort_notrack_noemg.mat',\n",
    "                               'Chips_20170505_TD_nosort_notrack_noemg.mat'\n",
    "                              ]\n",
    "\n",
    "GoodDataList_CO['S1']['Han'] = ['Han_COactpas_2017-10-31.mat',\n",
    "                             'Han_COactpas_2017-12-04.mat',\n",
    "                             'Han_COactpas_2017-10-24.mat',\n",
    "                             'Han_COactpas_2017-11-28.mat'\n",
    "                            ]\n",
    "\n",
    "GoodDataList_CO['S1']['Lando'] = ['Lando_20170731_TD_nosort_notrack_noemg.mat',\n",
    "                               'Lando_20170917_TD_nosort_notrack_noemg.mat',\n",
    "                               'Lando_20170803_TD_nosort_notrack_noemg.mat'\n",
    "                              ]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "60af89cc-d68b-4823-b866-15ac66df92c7",
   "metadata": {},
   "source": [
    "Adding the aggregate of *M1* and *PMd* as **MCx**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "dc8b2ec9-49d9-4ec0-9834-7239dadb4b14",
   "metadata": {},
   "outputs": [],
   "source": [
    "MCx = {}\n",
    "for area in ['M1', 'PMd', 'dualArea']:\n",
    "    for animal in GoodDataList_CO[area]:\n",
    "        if animal not in MCx:\n",
    "            MCx[animal] = []\n",
    "        MCx[animal].extend(GoodDataList_CO[area][animal])\n",
    "        MCx[animal] = list(set(MCx[animal]))\n",
    "\n",
    "GoodDataList_CO['MCx'] = MCx"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "8b8b1ede",
   "metadata": {},
   "outputs": [],
   "source": [
    "SingleSessionEx = {'Chewie2':['Chewie_CO_CS_2015-03-12.mat'],\n",
    "                   'Mihili':['Mihili_CO_FF_2014-02-17.mat'],\n",
    "                   'Jaco':['Jaco_CO_CS_2016-02-17.mat']\n",
    "                   }"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "29e3578e",
   "metadata": {},
   "source": [
    "Summarize number of trials and neurons for each session"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "ea47e5b4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>animal</th>\n",
       "      <th>file</th>\n",
       "      <th>areas</th>\n",
       "      <th>trials_all</th>\n",
       "      <th>trials_left</th>\n",
       "      <th>neurons_all</th>\n",
       "      <th>neurons_left</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Chewie</td>\n",
       "      <td>Chewie_CO_FF_2016-09-21.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>874</td>\n",
       "      <td>176</td>\n",
       "      <td>303</td>\n",
       "      <td>289</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Chewie</td>\n",
       "      <td>Chewie_CO_VR_2016-09-14.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>837</td>\n",
       "      <td>195</td>\n",
       "      <td>353</td>\n",
       "      <td>345</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Chewie</td>\n",
       "      <td>Chewie_CO_FF_2016-10-05.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>660</td>\n",
       "      <td>202</td>\n",
       "      <td>244</td>\n",
       "      <td>239</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Chewie</td>\n",
       "      <td>Chewie_CO_FF_2016-10-13.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>801</td>\n",
       "      <td>239</td>\n",
       "      <td>223</td>\n",
       "      <td>210</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Chewie</td>\n",
       "      <td>Chewie_CO_FF_2016-09-15.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>940</td>\n",
       "      <td>182</td>\n",
       "      <td>309</td>\n",
       "      <td>299</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Chewie</td>\n",
       "      <td>Chewie_CO_CS_2016-10-21.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>293</td>\n",
       "      <td>286</td>\n",
       "      <td>295</td>\n",
       "      <td>281</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Chewie</td>\n",
       "      <td>Chewie_CO_CS_2016-10-14.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>770</td>\n",
       "      <td>740</td>\n",
       "      <td>278</td>\n",
       "      <td>269</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Chewie</td>\n",
       "      <td>Chewie_CO_FF_2016-09-19.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>826</td>\n",
       "      <td>186</td>\n",
       "      <td>295</td>\n",
       "      <td>288</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Chewie2</td>\n",
       "      <td>Chewie_CO_CS_2015-03-19.mat</td>\n",
       "      <td>[M1_spikes]</td>\n",
       "      <td>1081</td>\n",
       "      <td>1026</td>\n",
       "      <td>74</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Chewie2</td>\n",
       "      <td>Chewie_CO_CS_2015-03-13.mat</td>\n",
       "      <td>[M1_spikes]</td>\n",
       "      <td>1089</td>\n",
       "      <td>1037</td>\n",
       "      <td>88</td>\n",
       "      <td>87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Chewie2</td>\n",
       "      <td>Chewie_CO_CS_2015-03-12.mat</td>\n",
       "      <td>[M1_spikes]</td>\n",
       "      <td>954</td>\n",
       "      <td>905</td>\n",
       "      <td>93</td>\n",
       "      <td>92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Chewie2</td>\n",
       "      <td>Chewie_CO_CS_2015-03-11.mat</td>\n",
       "      <td>[M1_spikes]</td>\n",
       "      <td>974</td>\n",
       "      <td>912</td>\n",
       "      <td>90</td>\n",
       "      <td>87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>Mihili</td>\n",
       "      <td>Mihili_CO_FF_2014-02-18.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>1010</td>\n",
       "      <td>225</td>\n",
       "      <td>159</td>\n",
       "      <td>130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>Mihili</td>\n",
       "      <td>Mihili_CO_VR_2014-03-04.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>925</td>\n",
       "      <td>203</td>\n",
       "      <td>115</td>\n",
       "      <td>106</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>Mihili</td>\n",
       "      <td>Mihili_CO_FF_2014-02-17.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>984</td>\n",
       "      <td>208</td>\n",
       "      <td>148</td>\n",
       "      <td>123</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>Mihili</td>\n",
       "      <td>Mihili_CO_VR_2014-03-06.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>993</td>\n",
       "      <td>217</td>\n",
       "      <td>129</td>\n",
       "      <td>122</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>Mihili</td>\n",
       "      <td>Mihili_CO_CS_2014-09-29.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>762</td>\n",
       "      <td>733</td>\n",
       "      <td>147</td>\n",
       "      <td>114</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>Mihili</td>\n",
       "      <td>Mihili_CO_VR_2014-03-03.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>859</td>\n",
       "      <td>209</td>\n",
       "      <td>117</td>\n",
       "      <td>109</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>Jaco</td>\n",
       "      <td>Jaco_CO_CS_2016-01-28.mat</td>\n",
       "      <td>[M1_spikes]</td>\n",
       "      <td>375</td>\n",
       "      <td>239</td>\n",
       "      <td>97</td>\n",
       "      <td>54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>Jaco</td>\n",
       "      <td>Jaco_CO_CS_2016-02-17.mat</td>\n",
       "      <td>[M1_spikes]</td>\n",
       "      <td>246</td>\n",
       "      <td>194</td>\n",
       "      <td>97</td>\n",
       "      <td>81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>Jaco</td>\n",
       "      <td>Jaco_CO_CS_2016-02-04.mat</td>\n",
       "      <td>[M1_spikes]</td>\n",
       "      <td>347</td>\n",
       "      <td>271</td>\n",
       "      <td>97</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>MrT</td>\n",
       "      <td>MrT_CO_VR_2013-09-05.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>819</td>\n",
       "      <td>174</td>\n",
       "      <td>65</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>MrT</td>\n",
       "      <td>MrT_CO_VR_2013-09-09.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>902</td>\n",
       "      <td>218</td>\n",
       "      <td>59</td>\n",
       "      <td>57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>MrT</td>\n",
       "      <td>MrT_CO_FF_2013-08-21.mat</td>\n",
       "      <td>[M1_spikes, PMd_spikes]</td>\n",
       "      <td>673</td>\n",
       "      <td>164</td>\n",
       "      <td>57</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     animal                         file                    areas  trials_all  \\\n",
       "0    Chewie  Chewie_CO_FF_2016-09-21.mat  [M1_spikes, PMd_spikes]         874   \n",
       "1    Chewie  Chewie_CO_VR_2016-09-14.mat  [M1_spikes, PMd_spikes]         837   \n",
       "2    Chewie  Chewie_CO_FF_2016-10-05.mat  [M1_spikes, PMd_spikes]         660   \n",
       "3    Chewie  Chewie_CO_FF_2016-10-13.mat  [M1_spikes, PMd_spikes]         801   \n",
       "4    Chewie  Chewie_CO_FF_2016-09-15.mat  [M1_spikes, PMd_spikes]         940   \n",
       "5    Chewie  Chewie_CO_CS_2016-10-21.mat  [M1_spikes, PMd_spikes]         293   \n",
       "6    Chewie  Chewie_CO_CS_2016-10-14.mat  [M1_spikes, PMd_spikes]         770   \n",
       "7    Chewie  Chewie_CO_FF_2016-09-19.mat  [M1_spikes, PMd_spikes]         826   \n",
       "8   Chewie2  Chewie_CO_CS_2015-03-19.mat              [M1_spikes]        1081   \n",
       "9   Chewie2  Chewie_CO_CS_2015-03-13.mat              [M1_spikes]        1089   \n",
       "10  Chewie2  Chewie_CO_CS_2015-03-12.mat              [M1_spikes]         954   \n",
       "11  Chewie2  Chewie_CO_CS_2015-03-11.mat              [M1_spikes]         974   \n",
       "12   Mihili  Mihili_CO_FF_2014-02-18.mat  [M1_spikes, PMd_spikes]        1010   \n",
       "13   Mihili  Mihili_CO_VR_2014-03-04.mat  [M1_spikes, PMd_spikes]         925   \n",
       "14   Mihili  Mihili_CO_FF_2014-02-17.mat  [M1_spikes, PMd_spikes]         984   \n",
       "15   Mihili  Mihili_CO_VR_2014-03-06.mat  [M1_spikes, PMd_spikes]         993   \n",
       "16   Mihili  Mihili_CO_CS_2014-09-29.mat  [M1_spikes, PMd_spikes]         762   \n",
       "17   Mihili  Mihili_CO_VR_2014-03-03.mat  [M1_spikes, PMd_spikes]         859   \n",
       "18     Jaco    Jaco_CO_CS_2016-01-28.mat              [M1_spikes]         375   \n",
       "19     Jaco    Jaco_CO_CS_2016-02-17.mat              [M1_spikes]         246   \n",
       "20     Jaco    Jaco_CO_CS_2016-02-04.mat              [M1_spikes]         347   \n",
       "21      MrT     MrT_CO_VR_2013-09-05.mat  [M1_spikes, PMd_spikes]         819   \n",
       "22      MrT     MrT_CO_VR_2013-09-09.mat  [M1_spikes, PMd_spikes]         902   \n",
       "23      MrT     MrT_CO_FF_2013-08-21.mat  [M1_spikes, PMd_spikes]         673   \n",
       "\n",
       "    trials_left  neurons_all  neurons_left  \n",
       "0           176          303           289  \n",
       "1           195          353           345  \n",
       "2           202          244           239  \n",
       "3           239          223           210  \n",
       "4           182          309           299  \n",
       "5           286          295           281  \n",
       "6           740          278           269  \n",
       "7           186          295           288  \n",
       "8          1026           74            73  \n",
       "9          1037           88            87  \n",
       "10          905           93            92  \n",
       "11          912           90            87  \n",
       "12          225          159           130  \n",
       "13          203          115           106  \n",
       "14          208          148           123  \n",
       "15          217          129           122  \n",
       "16          733          147           114  \n",
       "17          209          117           109  \n",
       "18          239           97            54  \n",
       "19          194           97            81  \n",
       "20          271           97            55  \n",
       "21          174           65            60  \n",
       "22          218           59            57  \n",
       "23          164           57            56  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# warnings.filterwarnings(\"ignore\")\n",
    "# rows = []\n",
    "\n",
    "# good_files = []\n",
    "# for animal in GoodDataList_CO['MCx'].keys():\n",
    "#     for file in GoodDataList_CO['MCx'][animal]:\n",
    "#         good_files.append(str(root) + f'/{animal}/{file}')\n",
    "\n",
    "# for file in good_files:\n",
    "#     raw_df = pyal.mat2dataframe(file, shift_idx_fields=True)\n",
    "#     df = defs.prep_general(raw_df)\n",
    "\n",
    "#     dic = {\n",
    "#         'animal': file.split(os.sep)[-2],\n",
    "#         'file': file.split(os.sep)[-1],\n",
    "#         'areas': [x for x in list(raw_df.columns) if '_spikes' in x],\n",
    "#         'trials_all': len(raw_df),\n",
    "#         'trials_left': len(df),\n",
    "#         'neurons_all': sum([raw_df[x][0].shape[1] for x in list(raw_df.columns) if '_spikes' in x]),\n",
    "#         'neurons_left': df['MCx_spikes'][0].shape[1] \n",
    "#     }\n",
    "#     rows.append(dic)\n",
    "\n",
    "# summary = pd.DataFrame(rows)\n",
    "# summary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "ded490a8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "      <th>sem</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>animal</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Chewie</th>\n",
       "      <td>277.500000</td>\n",
       "      <td>14.257830</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Chewie2</th>\n",
       "      <td>84.750000</td>\n",
       "      <td>4.090130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Jaco</th>\n",
       "      <td>63.333333</td>\n",
       "      <td>8.838049</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mihili</th>\n",
       "      <td>117.333333</td>\n",
       "      <td>3.756476</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MrT</th>\n",
       "      <td>57.666667</td>\n",
       "      <td>1.201850</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               mean        sem\n",
       "animal                        \n",
       "Chewie   277.500000  14.257830\n",
       "Chewie2   84.750000   4.090130\n",
       "Jaco      63.333333   8.838049\n",
       "Mihili   117.333333   3.756476\n",
       "MrT       57.666667   1.201850"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# summary.groupby('animal')['neurons_left'].agg(['mean', 'sem'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "24ea9e4b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.10.5 ('cca')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.5"
  },
  "vscode": {
   "interpreter": {
    "hash": "f438ab41c639bccf4a0690d593feedbc6f327eadb4a78567565a57c35fedcdae"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
